import { HttpException } from '@nestjs/common';
import { HTTP_CODE } from '../enum/http-code.enum';
import { ErrMsgDetailType } from '../type/response.type';
export class BusinessException extends HttpException {
  private _msg: string; // 自定义信息
  private _code: string; // 自定义编码
  // 特殊 为流程
  private _processMsg: string;
  private _processUrl: string;
  constructor(
    type: ErrMsgDetailType,
    msg?: string,
    processMsg?: string,
    processUrl?: string,
  ) {
    super({ message: msg, statusCode: 200 }, HTTP_CODE.SUCCESS, {
      cause: type.msg,
      description: msg,
    });
    // 自定义信息及编码
    this._msg = type.msg + `${msg ? ' - ' + msg : ''}`;
    this._code = type.code;
    this._processMsg = processMsg;
    this._processUrl = processUrl;
  }

  public get getMsg(): string {
    return this._msg;
  }
  public get getCode(): string {
    return this._code;
  }
  public get getProcessMsg(): string {
    return this._processMsg;
  }
  public get getProcessUrl(): string {
    return this._processUrl;
  }
}
